#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;


class Solution {
public:
    //令f[i]为前i个数字的最长摆动序列
    int wiggleMaxLength(vector<int>& nums) {
        int down =1,up =1;
        for(int i=1;i<nums.size();i++){
            if(nums[i]-nums[i-1]>0){
                up = down+1;
            }
            else if(nums[i]-nums[i-1]<0){
                down = up+1;
            }
        }
        return nums.size()==0?0:max(up,down);
    }
};


